<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<link rel="stylesheet" type="text/css" th:href="@{/static/layui/css/layui.css}" />
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/organization/thesame.css}" />
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/footer.css}" media="all">
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/wardRound/rightCon.css}" media="all" />
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/wardRound/popCss.css}" media="all" />

	</head>
	<body class="layui-layout-body">
	<input id="userNo" type="hidden" name="userNo" th:value="${userNo}" />
	<input id="batchNo" type="hidden" name="batchNo" th:value="${batchNo}" />
		<div class="layui-body">
			<div class="add-title pad25px"><!--<span class="mr10px"><img th:src="@{/static/img/return_icon.png}"></span>--><span>新建档案</span></div>
				<div class="new-add-box new-add-box-width bgWhite box-shadows border-radius4">
					<div class="add-box-scroll">
						<div class="border-bot5px border-radius4 pad25px">
							<dl class="per-look-dl">
								<dt>
									<img th:if="${userInfo['headExist']}==1" th:src="${userInfo['headUrl']}" class="block">
									<img th:if="${userInfo['headExist']}==0" th:src="@{/static/img/defaultHead.jpg}" class="block">
								</dt>
								<dd>
									<div class="overflow">
										<p class="left">
											<span th:text="${userInfo['userName']}"></span>
											<span class="border-bggray" th:text="${userInfo['bedInfo']}"></span>
										</p>
										<p class="right">
											<span class="border-bgred" th:if="${userInfo['cognitionStatus']}==1">认知问题</span>
											<span th:onclick="nursingLevelPicLayerOpen([[${userInfo.nursingImg}]])" class="border-bgred cursor">
												<em th:text="${userInfo['nursingDegree']}"></em>
												<em class="look-em border-bgred textCenter">?</em>
											</span>
											<span class="border-bgred" th:text="${userInfo['assessmentDegree']}"></span>
										</p>
									</div>
									<div>
										<span th:text="${userInfo['userSex']}"></span>
										<span th:text="${userInfo['userAge']}+'岁'"></span>
										<span th:text="${userInfo['eduction']}"></span>
										<span th:text="${userInfo['securityType']}"></span>
										<span th:text="${userInfo['userAddress']}"></span>
									</div>
									<div>
										<span class="border-bggreen" th:text="'合同截止：'+${userInfo['contractEndDate']}"></span>
										<span class="border-bggreen" th:text="'下次护理评估时间：'+${userInfo['nursingDate']}"></span>
										<span class="border-bggreen" th:text="'评估有效期：'+${userInfo['assessmentDate']}"></span>
									</div>
								</dd>
							</dl>
						</div>
						<div class="mb25px pad25px">
							<ul class="inform-title mb25px">
								<li class="current" style="cursor: default">健康档案</li>
								<li class="current" style="cursor: default">体格检查</li>
								<li class="current" style="cursor: default">实验室检查</li>
								<li class="current" style="cursor: default">初步诊断</li>
								<li class="current" style="cursor: default">诊疗计划</li>
							</ul>
							<article class="mb25px">
								<div class="new-add-form-con new-add-form-three">
									<ul class="overflow">
										<li class="width-three">
											<div>
												<label>其他说明：</label>
												<h6 class="green cursor" id="addButton"><img src="../static/img/icon_muban.png" alt="模板">模板</h6>
											</div>
											<div class="border-radius4 border1px pad15px">
												<!--<div>1、控制监测血压、心律</div>
												<div>2、清淡低盐、低嘌呤饮食，适当补钙</div>
												<div>3、注意休息、适当户外活动，防止跌倒 </div>
												<div>4、如有不适，门诊随访。</div>-->
												<textarea id="inputText" style="width: 100%;resize: none;" rows="10">[[${preliminaryDiagnosis?.treatmentPlanning}]]</textarea>
											</div>
										</li>
									</ul>
								</div>
							</article>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="layui-footer layui-footer-one">
			<div class="btn-con textCenter">
				<span class="btn-three cursor" id="prevButton">上一步</span>
				<span class="btn-two cursor" id="submitButton">提交</span>
			</div>
		</div>
		<div id="checkInfoDiv" style="display: none;">
			<li th:each="item:${checkInfo}"><span><input type="checkbox" th:data-id="${item.checkNo}" th:data-name="${item.checkName}" lay-skin="primary" th:title="${item.checkName}"></span></li>
		</div>
		<div id="pop-nursingLevelPicLayerOpen" style="display: none;">
			<div class="pop-up">
				<!-- 查看护理等级 -->
				<div>
					<div class="pop-title relative overflow mb15px">
						<span class="ml15px">护理等级</span>
						<p class="right"><img src="../static/elderlyInfo/img/close_icon.png" class="block pop-close"><p>
					</div>
					<div class="mt10px">
						<p><img id="nursingPic" th:src="${userInfo.nursingImg}" alt=""></p>
					</div>
				</div>
			</div>
		</div>
		<script th:src="@{/static/js/jquery-2.1.3.min.js}"></script>
		<script th:src="@{/static/js/nursingImg.js}"></script>
		<script th:src="@{/static/layui/layui.js}"></script>
		<script>
			var basePath = $("input#basePathInput",parent.document).val();
			var saveFlag = true;

			//左侧菜单栏
			layui.use(['element','layer',"form"], function() {
				var element = layui.element;
				var layer = layui.layer;
				var form = layui.form;
				$("span#prevButton").on("click",function (e) {
					window.location.href=basePath+"/wardRound/wardRound_four"+"?userNo="+$("#userNo").val()+"&batchNo="+$("input#batchNo").val();
				})

				$("span#submitButton").on("click",function (e) {
					let flag = true;
					let text = $("textarea#inputText").val();
					if(!isNotNull(text)){
						text = "";
					}
					if (flag) {
						if (saveFlag) {
							saveFlag = false;
							$.ajax({
								url: "../wardRound/saveTreatmentPlan",
								type: "post",
								dataType: "json",
								data: {"batchNo": $("input#batchNo").val(),"text":text,"userNo":$("input#userNo").val()},
								success: function (result) {
									saveFlag = true;
									if (result.code == 200) {
										/*window.location.href=basePath+"/wardRound/index";*/
										layer.msg(result.msg);
										openPdf(layer);
									}else{
										layer.msg(result.msg);
									}
								}
							})
						}
					}
				})

				$("h6#addButton").unbind().on("click",function (e) {
					layerOpen();
				})

				//弹层
				function layerOpen(){
					let html = '<div id="pop-con"><div class="pop-up"><div><div class="pop-title relative overflow mb15px"><span class="ml15px">治疗计划模版</span><p class="right"><img src="../static/img/close_icon.png" class="block pop-close"><p></div><nav class="mt20px mb20px layui-form lh40px"><ul id="checkInfoUl">';
					html += $("div#checkInfoDiv").html();
					html += '</ul></nav><div class="btn-con textCenter"><span class="btn-one pop-close cursor">取&nbsp;消</span><span class="btn-two" id="submitSelectButton">确&nbsp;定</span></div></div></div></div>';
					layer.open({
						type: 1,
						title: false,
						closeBtn: false,
						area: ['520px', '500px'],
						shade: 0.6,
						id: 'payCons',
						btnAlign: 'c',
						moveType: 1,
						shadeClose: true,
						content: html,
						success: function() {
							form.render();
							//关闭弹层
							$(".pop-close").click(function() {
								layer.closeAll();
							});
							$("span#submitSelectButton").on("click",function (e) {
								let text = "";
								$("ul#checkInfoUl li input[type='checkbox']:checked").each(function (i,v) {
									text += (i+1) + "、" + $(this).data("name") + "\r";
								})
								$("textarea#inputText").val(text);
								layer.closeAll();
							})
						}
					});
				}
			});

			function openPdf(layer) {
				layer.msg('查房报告生成中...', {
					icon: 16
					,shade: 0.01,
					time:50000000
				});
				let batchNo = $("input#batchNo").val();
				let userNo = $("input#userNo").val();
				$.ajax({
					url:"../wardRound/getPdfInfo",
					type:"post",
					dataType:"json",
					data:{"batchNo":batchNo,"userNo":userNo},
					success:function (result) {
						if(result.code == 200){
							let data = result.data;
							let html = '<div id="pop-con"><div class="pop-up"><div><div class="pop-title relative overflow mb15px"><span class="ml15px">查房报告</span><p class="right pop-close"><img src="../static/img/close_icon.png" class="block"><p></div><article class="mt20px mb20px"><div class="overflow relative mb20px textCenter"><p class="textCenter f16px fb">'+getNotNull(result.title)+'</p><p class="inline-block green cursor" id="pdfReturnList"><img src="../static/img/pdf_return.png" alt="返回列表" class="mr20px" style="vertical-align: -6px;">返回列表</p><p class="inline-block green cursor" style="right: 0; top: 0;" id="downloadPdf"><img src="../static/img/icon_pdf.png" alt="pdf下载" class="mr5px" style="vertical-align: -6px;">下载</p></div><nav class="f14px lh40px"><ul class="underline"><li class="underline-one"><p><em>部门</em><span>'+getNotNull(data.userInfo.building_name)+'</span></p><p><em>室号</em><span>'+getNotNull(data.userInfo.room_name)+'</span></p><p><em>床号</em><span>'+getNotNull(data.userInfo.bed_name)+'</span></p><p><em>入院日期</em><span>'+getNotNull(data.inspectInfo.in_date)+'</span></p><p><em>住院号</em><span>'+getNotNull(data.inspectInfo.in_no)+'</span></p></li><ul class="overflow"><li class="left"><div><p><em>姓名</em><span>'+getNotNull(data.userInfo.user_name)+'</span></p></div><div><p><em>性别</em><span>'+getNotNull(data.inspectInfo.sex)+'</span></p></div><div><p><em>出生年月</em><span>'+getNotNull(data.userInfo.birth_date)+'</span></p></div><div><p><em>民族</em><span>'+getNotNull(data.inspectInfo.nation)+'</span></p><p><em>籍贯</em><span>'+getNotNull(data.userInfo.native_place)+'</span></p></div></li><li class="right"><div><p><em>护理等级</em><span>'+getNotNull(data.userInfo.nursing_cost_name)+'</span></p></div><div><p><em>职业</em><span>'+getNotNull(data.inspectInfo.job)+'</span></p></div><div><p><em>工作单位</em><span>'+getNotNull(data.inspectInfo.work_place)+'</span></p></div><div><p><em>供病史者</em><span>'+getNotNull(data.inspectInfo.history_info)+'</span></p></div></li></ul><li class="underline-posi"><p class="relative"><em>家庭地址</em><span>'+getNotNull(data.inspectInfo.address)+'</span></p></li><li><div>主诉：</div><div class="underline-chunk"><p><span>'+getNotNull(data.inspectInfo.zhu_su)+'</span></p></div></li><li><div>现病史：</div><div class="underline-chunk"><p><span>'+getNotNull(data.inspectInfo.medical_history)+'</span></p></div></li><li><div>既往史：（曾患疾病、既往体质）：</div><div class="underline-chunk"><p><span>'+getNotNull(data.inspectInfo.disease_info)+'</span></p></div></li><li><div>体格检查：</div><div class="underline-one"><p><em>体温</em><span>'+getNotNull(data.inspectInfo.temperature)+'</span><em>℃</em></p><p><em>脉搏</em><span>'+getNotNull(data.inspectInfo.pulse)+'</span><em>次/分钟</em></p><p><em>呼吸</em><span>'+getNotNull(data.inspectInfo.breath)+'</span><em>次/分钟</em></p><p><em>血压</em><span>'+getNotNull(data.inspectInfo.blood_pressure)+'</span><em>mmhg</em></p></div></li><li><div>一般情况（1.以写慢性体征为主；2.皮肤、淋巴、心肺、腹、四肢活动情况、神经反射情况）：</div><div class="underline-chunk"><p><span>'+getNotNull(data.inspectInfo.inspect_describe)+'</span></p></div></li><li><div>实验室检查：</div><div class="underline-chunk underline-div">';
									if(data.laboratory && data.laboratory.length > 0){
										data.laboratory.forEach(function (v,i) {
											html += '<div><span>'+getNotNull(v.name)+'：'+getNotNull(v.text)+'</span></div>';
										})
									}
									html += '</div></li><li><div>初步诊断：</div><div class="underline-chunk underline-div">';
									if(data.disease && data.disease.length > 0){
										data.disease.forEach(function (v,i) {
											html += '<div><span>'+(i+1)+"、"+getNotNull(v.checkName)+ '</span></div>';
										})
									}
									html += '</div></li><li><div>诊疗计划：</div><div class="underline-chunk underline-div">\n';

									if(data.treatmentPlanning && data.treatmentPlanning.length > 0){
										data.treatmentPlanning.forEach(function (v,i) {
											html += '<div><span>'+getNotNull(v)+ '</span></div>';
										})
									}
									html += '</div></li><ul class="overflow"><div class="left"><div><p><em>医师签名</em><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></p></div></div><div class="right"><div><p><span>'+data.year+'</span><em>年</em><span>'+data.month+'</span><em>月</em><span>'+data.day+'</span><em>日</em></p></div></div></ul></ul></nav></article></div></div></div>';
							layer.closeAll();
							layer.open({
								type: 1,
								title: false, //不显示标题栏
								closeBtn: false,
								area: ['720px', '90%'],
								shade: 0.6,
								id: 'payCons', //设定一个id，防止重复弹出
								btnAlign: 'c',
								moveType: 1, //拖拽模式，0或者1
								shadeClose: true, //设置允许点遮罩关闭
								content: html,
								success: function() {
									//关闭弹层
									$(".pop-close").click(function() {
										layer.closeAll();
									});

									$("p#downloadPdf").on("click",function () {
										window.location.href="../wardRound/createPdf?userNo="+userNo+"&batchNo="+batchNo;
										layer.closeAll();
									})

									$("p#pdfReturnList").on("click",function () {
										layer.closeAll();
										window.location.href="../wardRound/index";
									})
								},

							});
						}else{
							layer.msg("生成检查报告失败！");
						}
					}
				})

			}

			function isNotNull(val) {
				if(val && $.trim(val) && val != 'undefined' && val != 'null'){
					return true;
				}else{
					return false;
				}
			}

			function getNotNull(val) {
				if(val && $.trim(val) && val != 'undefined' && val != 'null'){
					return val;
				}else{
					return "";
				}
			}
		</script>
	</body>

</html>
